<template>
  <div class="news">
    <!-- 导航区 -->
    <ul>
      <!-- 传递query参数 -->
      <li v-for="item of newsList" :key="item.id">
        <router-link
          :to="{
            name: 'xiangqing',
            query: { id: item.id, title: item.title, content: item.content },
          }"
          >{{ item.title }}</router-link
        >
      </li>
      <!-- 传递params参数 -->
      <!-- <li v-for="item of newsList" :key="item.id">
        <router-link
          :to="{
            name: 'xiangqing',
            params: {
              id: item.id,
              title: item.title,
              content: item.content,
            },
          }"
          >{{ item.title }}</router-link
        >
      </li> -->
    </ul>
    <!-- 展示区 -->
    <div class="news-content">
      <router-view></router-view>
    </div>
  </div>
</template>

<script setup lang="ts" name="News">
import { reactive } from "vue";

const newsList = reactive([
  { id: "ndks01", title: "抗癌食物", content: "西瓜" },
  { id: "ndks02", title: "如何一夜暴富", content: "学IT" },
  { id: "ndks03", title: "震惊，万万没想到", content: "明天是周一" },
  { id: "ndks04", title: "好消息", content: "快放假了" },
]);
</script>

<style scoped>
/* 新闻 */
.news {
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  height: 100%;
}
.news ul {
  margin-top: 30px;
  /* list-style: none; */
  padding-left: 10px;
}
.news li::marker {
  color: green;
}
.news li > a {
  font-size: 18px;
  line-height: 40px;
  text-decoration: none;
  color: #64967e;
  text-shadow: 0 0 1px rgb(0, 84, 0);
}
.news-content {
  width: 70%;
  height: 90%;
  border: 1px solid;
  margin-top: 20px;
  border-radius: 10px;
}
</style>
